
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3.2 创建通用子模块 · 大数据 bigdata_mallanalyze_atguigu 课堂笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content=" 李振超">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-page-toc-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-solarizedlight.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-change_girls/girls.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.html" />
    
    
    <link rel="prev" href="31-chuang-jian-fu-gong-cheng.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.atguigu.com/" target="_blank" class="custom-link">联系我们</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        <li class="header">第 1 部分 电商分析系统介绍</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    第 1 章 项目简介
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../11-xiang-mu-zheng-ti-jie-shao.html">
            
                <a href="../11-xiang-mu-zheng-ti-jie-shao.html">
            
                    
                    1.1 项目整体介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="../12-xiang-mu-zheng-ti-jia-gou.html">
            
                <a href="../12-xiang-mu-zheng-ti-jia-gou.html">
            
                    
                    1.2 项目整体架构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3" data-path="../13-ye-wu-xu-qiu.html">
            
                <a href="../13-ye-wu-xu-qiu.html">
            
                    
                    1.3 数据源分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.4" data-path="../14-xiang-mu-xu-qiu.html">
            
                <a href="../14-xiang-mu-xu-qiu.html">
            
                    
                    1.4 项目需求
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1.html">
            
                <a href="../chapter1.html">
            
                    
                    第 2 章 预备知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../di-3-zhang-xiang-mu-da-jian.html">
            
                <a href="../di-3-zhang-xiang-mu-da-jian.html">
            
                    
                    第 3 章 项目搭建
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="31-chuang-jian-fu-gong-cheng.html">
            
                <a href="31-chuang-jian-fu-gong-cheng.html">
            
                    
                    3.1 创建父工程
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.2" data-path="32-chuang-jian-gong-zuo-zi-mo-kuai.html">
            
                <a href="32-chuang-jian-gong-zuo-zi-mo-kuai.html">
            
                    
                    3.2 创建通用子模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.html">
            
                <a href="33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.html">
            
                    
                    3.3 创建模拟数据子模块
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">第 2 部分 电商分析系统需求实现</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-4-zhang-xu-qiu-1.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-4-zhang-xu-qiu-1.html">
            
                    
                    第 4 章 需求1: Top10 热门品类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-5-zhang-xu-qiu-2-top10-remen-pin-lei-zhong-de-top10-session-tong-ji.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-5-zhang-xu-qiu-2-top10-remen-pin-lei-zhong-de-top10-session-tong-ji.html">
            
                    
                    第 5 章 需求2: Top10热门品类中的 Top10 活跃 Session 统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-6-zhang-xu-qiu-3-dan-ye-mian-tiao-zhuan-lv.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-6-zhang-xu-qiu-3-dan-ye-mian-tiao-zhuan-lv.html">
            
                    
                    第 6 章 需求3: 页面单条转化率统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-7-zhang-xu-qiu-4-ge-qu-yu-re-men-shang-pin-top3.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-7-zhang-xu-qiu-4-ge-qu-yu-re-men-shang-pin-top3.html">
            
                    
                    第 7 章 需求4: 各区域热门商品 Top3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                    
                    第 8 章 需求5:  广告黑名单实时统计
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/81-li-xian-xiang-mu-yu-bei-zhi-shi.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/81-li-xian-xiang-mu-yu-bei-zhi-shi.html">
            
                    
                    8.1 离线项目预备知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.2" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/81-shi-shi-huan-jing-da-jian.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/81-shi-shi-huan-jing-da-jian.html">
            
                    
                    8.2 实时环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.3" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/82-xu-qiu-5-guang-gao-hei-ming-dan-shi-shi-tong-ji.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/82-xu-qiu-5-guang-gao-hei-ming-dan-shi-shi-tong-ji.html">
            
                    
                    8.3 需求5: 广告黑名单实时统计
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-9-zhang-xu-qiu-6-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-9-zhang-xu-qiu-6-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                    
                    第 9 章 需求6: 广告点击量实时统计 
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-10-zhang-xu-qiu-7-mei-tian-mei-di-qu-re-men-guang-gao-top3.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-10-zhang-xu-qiu-7-mei-tian-mei-di-qu-re-men-guang-gao-top3.html">
            
                    
                    第 10 章 需求7: 每天每地区 热门广告 Top3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-11-zhang-xin-zeng-xu-6c423a-zui-jin-1-xiao-shi-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                <a href="../di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-11-zhang-xin-zeng-xu-6c423a-zui-jin-1-xiao-shi-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                    
                    第 11 章 新增需求: 最近 1 小时广告点击量实时统计
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >3.2 创建通用子模块</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="32-&#x521B;&#x5EFA;&#x901A;&#x7528;&#x5B50;&#x6A21;&#x5757;">3.2 &#x521B;&#x5EFA;&#x901A;&#x7528;&#x5B50;&#x6A21;&#x5757;</h1>
<p>&#x901A;&#x7528;&#x6A21;&#x5757;&#x4E3B;&#x8981;&#x662F;&#x653E;&#x516C;&#x5171;&#x7684;&#x4F9D;&#x8D56;&#x5305;&#x548C;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x4EE5;&#x53CA;&#x7528;&#x6237;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x4E00;&#x4E9B;&#x5DE5;&#x5177;&#x7C7B;, &#x6837;&#x4F8B;&#x7C7B;&#x7B49;&#x3002;</p>
<h2 id="321-&#x6DFB;&#x52A0;&#x4F9D;&#x8D56;">3.2.1 &#x6DFB;&#x52A0;&#x4F9D;&#x8D56;</h2>
<pre class="language-"><code class="lang-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependencies</span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.alibaba<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>fastjson<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.2.47<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>


    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- common-pool2&#x4F7F;&#x7528;&#x7684;&#x662F;&#x9762;&#x5411;&#x63A5;&#x53E3;&#x7684;&#x7F16;&#x7A0B;&#xFF0C;&#x5B83;&#x4E3A;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x7684;&#x662F;&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x7684;&#x5BF9;&#x8C61;&#x6C60;&#x7BA1;&#x7406;&#x65B9;&#x5F0F;&#xFF0C;
             &#x6839;&#x636E;&#x6211;&#x4EEC;&#x4E1A;&#x52A1;&#x7684;&#x4E0D;&#x540C;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x91CD;&#x5199;&#x6216;&#x5B9E;&#x73B0;&#x4E00;&#x4E9B;&#x65B9;&#x6CD5;&#x548C;&#x63A5;&#x53E3; --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.apache.commons<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>commons-pool2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>2.4.2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- &#x6709;&#x52A9;&#x4E8E;&#x4EE5;&#x5404;&#x79CD;&#x683C;&#x5F0F;&#x8BFB;&#x53D6;&#x914D;&#x7F6E;/&#x504F;&#x597D;&#x6587;&#x4EF6;&#x7684;&#x5DE5;&#x5177; --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.apache.commons<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>commons-configuration2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>2.2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- commons-beanutil&#x4E2D;&#x5305;&#x62EC;&#x5927;&#x91CF;&#x548C;JavaBean&#x64CD;&#x4F5C;&#x6709;&#x5173;&#x7684;&#x5DE5;&#x5177;&#x65B9;&#x6CD5;&#xFF0C;
             &#x4F7F;&#x7528;&#x5B83;&#x80FD;&#x591F;&#x8F7B;&#x677E;&#x5229;&#x7528;Java&#x53CD;&#x5C04;&#x673A;&#x5236;&#x6765;&#x5B8C;&#x6BD5;&#x4EE3;&#x7801;&#x4E2D;&#x6240;&#x987B;&#x8981;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x800C;&#x4E0D;&#x987B;&#x8981;&#x5177;&#x4F53;&#x7814;&#x7A76;&#x53CD;&#x5C04;&#x7684;&#x539F;&#x7406;&#x548C;&#x4F7F;&#x7528; --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>commons-beanutils<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>commons-beanutils<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.9.3<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!--mysql &#x9A71;&#x52A8;--&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>mysql<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mysql-connector-java<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>5.1.44<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!--kafka &#x5BA2;&#x6237;&#x7AEF;--&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.apache.kafka<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>kafka-clients<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>0.10.2.1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.apache.spark<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>spark-streaming_2.11<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.apache.spark<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>spark-streaming-kafka-0-10_2.11<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!-- https://mvnrepository.com/artifact/redis.clients/jedis --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>redis.clients<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>jedis<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>2.9.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>

    <span class="token comment">&lt;!--&#x963F;&#x91CC;&#x5DF4;&#x5DF4;&#x51FA;&#x54C1;&#x7684;&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x6C60;. druid &#x662F;&#x76EE;&#x524D;&#x6700;&#x597D;&#x7684;&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x6C60;--&gt;</span>
    <span class="token comment">&lt;!-- https://mvnrepository.com/artifact/com.alibaba/druid --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.alibaba<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>druid<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.1.10<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!-- https://mvnrepository.com/artifact/net.sf.json-lib/json-lib --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>net.sf.json-lib<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>json-lib<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>2.4<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>classifier</span><span class="token punctuation">&gt;</span></span>jdk15<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>classifier</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!-- https://mvnrepository.com/artifact/org.json4s/json4s-native --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.json4s<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>json4s-native_2.11<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>3.2.11<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>

    <span class="token comment">&lt;!-- https://mvnrepository.com/artifact/org.json4s/json4s-jackson --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.json4s<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>json4s-jackson_2.11<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>3.2.11<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependencies</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>build</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plugins</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- &#x6253;&#x5305;&#x63D2;&#x4EF6;, &#x5426;&#x5219; scala &#x7C7B;&#x4E0D;&#x4F1A;&#x7F16;&#x8BD1;&#x75C5;&#x6253;&#x5305;&#x8FDB;&#x53BB; --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plugin</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>net.alchim31.maven<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>scala-maven-plugin<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>plugin</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>plugins</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>build</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<hr>
<h2 id="322-&#x5728;resources&#x4E2D;&#x6DFB;&#x52A0;&#x8D44;&#x6E90;&#x6587;&#x4EF6;">3.2.2 &#x5728;<code>resources</code>&#x4E2D;&#x6DFB;&#x52A0;&#x8D44;&#x6E90;&#x6587;&#x4EF6;</h2>
<h3 id="log4jproperties&#x6587;&#x4EF6;"><code>log4j.properties</code>&#x6587;&#x4EF6;</h3>
<p>&#x6846;&#x67B6;&#x4F1A;&#x81EA;&#x52A8;&#x8BFB;&#x53D6;<code>log4j</code>&#x7684;&#x914D;&#x7F6E;</p>
<pre class="language-"><code class="lang-java"># &#x53EA;&#x8F93;&#x51FA;&#x9519;&#x8BEF;&#x7EA7;&#x522B;&#x7684;&#x65E5;&#x5FD7;<span class="token punctuation">.</span>
log4j<span class="token punctuation">.</span>rootLogger<span class="token operator">=</span>error<span class="token punctuation">,</span> stdout<span class="token punctuation">,</span>R
# &#x63A7;&#x5236;&#x53F0;
log4j<span class="token punctuation">.</span>appender<span class="token punctuation">.</span>stdout<span class="token operator">=</span>org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>log4j<span class="token punctuation">.</span>ConsoleAppender
log4j<span class="token punctuation">.</span>appender<span class="token punctuation">.</span>stdout<span class="token punctuation">.</span>layout<span class="token operator">=</span>org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>log4j<span class="token punctuation">.</span>PatternLayout
log4j<span class="token punctuation">.</span>appender<span class="token punctuation">.</span>stdout<span class="token punctuation">.</span>layout<span class="token punctuation">.</span>ConversionPattern<span class="token operator">=</span><span class="token operator">%</span>d<span class="token punctuation">{</span>yyyy<span class="token operator">-</span>MM<span class="token operator">-</span>dd HH<span class="token operator">:</span>mm<span class="token operator">:</span>ss<span class="token punctuation">,</span>SSS<span class="token punctuation">}</span>  <span class="token operator">%</span><span class="token number">5</span>p <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span><span class="token operator">%</span><span class="token number">2</span>t<span class="token punctuation">]</span>  <span class="token operator">%</span><span class="token operator">-</span><span class="token function">8c</span><span class="token punctuation">(</span>line<span class="token operator">:</span><span class="token operator">%</span><span class="token number">2</span>L<span class="token punctuation">)</span>  <span class="token operator">:</span>  <span class="token operator">%</span>m<span class="token operator">%</span>n
# &#x53EF;&#x6EDA;&#x52A8;&#x7684;&#x6587;&#x4EF6;
log4j<span class="token punctuation">.</span>appender<span class="token punctuation">.</span>R<span class="token operator">=</span>org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>log4j<span class="token punctuation">.</span>RollingFileAppender
log4j<span class="token punctuation">.</span>appender<span class="token punctuation">.</span>R<span class="token punctuation">.</span>File<span class="token operator">=</span><span class="token punctuation">.</span><span class="token punctuation">.</span>/log<span class="token operator">/</span>agent<span class="token punctuation">.</span>log
log4j<span class="token punctuation">.</span>appender<span class="token punctuation">.</span>R<span class="token punctuation">.</span>MaxFileSize<span class="token operator">=</span><span class="token number">1024</span>KB
log4j<span class="token punctuation">.</span>appender<span class="token punctuation">.</span>R<span class="token punctuation">.</span>MaxBackupIndex<span class="token operator">=</span><span class="token number">1</span>
log4j<span class="token punctuation">.</span>appender<span class="token punctuation">.</span>R<span class="token punctuation">.</span>layout<span class="token operator">=</span>org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>log4j<span class="token punctuation">.</span>PatternLayout
log4j<span class="token punctuation">.</span>appender<span class="token punctuation">.</span>R<span class="token punctuation">.</span>layout<span class="token punctuation">.</span>ConversionPattern<span class="token operator">=</span><span class="token operator">%</span>d<span class="token punctuation">{</span>yyyy<span class="token operator">-</span>MM<span class="token operator">-</span>dd HH<span class="token operator">:</span>mm<span class="token operator">:</span>ss<span class="token punctuation">,</span>SSS<span class="token punctuation">}</span>  <span class="token operator">%</span><span class="token number">5</span>p <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span><span class="token operator">%</span><span class="token number">2</span>t<span class="token punctuation">]</span>  <span class="token operator">%</span><span class="token operator">-</span><span class="token function">8c</span><span class="token punctuation">(</span>line<span class="token operator">:</span><span class="token operator">%</span><span class="token number">2</span>L<span class="token punctuation">)</span>  <span class="token operator">:</span>  <span class="token operator">%</span>m<span class="token operator">%</span>n
</code></pre>
<h3 id="configproperties-&#x6587;&#x4EF6;"><code>config.properties</code> &#x6587;&#x4EF6;</h3>
<p>&#x4E00;&#x4E9B;&#x914D;&#x7F6E;, &#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x9700;&#x8981;&#x624B;&#x52A8;&#x8BFB;&#x53D6;</p>
<pre class="language-"><code class="lang-java"># jdbc&#x914D;&#x7F6E;
jdbc<span class="token punctuation">.</span>maxActive<span class="token operator">=</span><span class="token number">10</span>
# &#x6839;&#x636E;&#x81EA;&#x5DF1;&#x60C5;&#x51B5;&#x8FDB;&#x884C;&#x4FEE;&#x6539;
jdbc<span class="token punctuation">.</span>url<span class="token operator">=</span>jdbc<span class="token operator">:</span>mysql<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>hadoop201<span class="token operator">:</span><span class="token number">3306</span><span class="token operator">/</span>sparkmall<span class="token operator">?</span>useUnicode<span class="token operator">=</span><span class="token boolean">true</span><span class="token operator">&amp;</span>characterEncoding<span class="token operator">=</span>utf8<span class="token operator">&amp;</span>rewriteBatchedStatements<span class="token operator">=</span><span class="token boolean">true</span>
jdbc<span class="token punctuation">.</span>user<span class="token operator">=</span>root
jdbc<span class="token punctuation">.</span>password<span class="token operator">=</span>aaa

# Kafka broker&#x914D;&#x7F6E;
kafka<span class="token punctuation">.</span>broker<span class="token punctuation">.</span>list<span class="token operator">=</span>hadoop201<span class="token operator">:</span><span class="token number">9092</span><span class="token punctuation">,</span>hadoop202<span class="token operator">:</span><span class="token number">9092</span><span class="token punctuation">,</span>hadoop203<span class="token operator">:</span><span class="token number">9092</span>

# Redis&#x914D;&#x7F6E;
redis<span class="token punctuation">.</span>host<span class="token operator">=</span>hadoop201
redis<span class="token punctuation">.</span>port<span class="token operator">=</span><span class="token number">6379</span>

# hive&#x6570;&#x636E;&#x5E93;&#x540D;&#x5B57;<span class="token punctuation">(</span>&#x9009;&#x914D;<span class="token punctuation">)</span>
hive<span class="token punctuation">.</span>database<span class="token operator">=</span>sparkmall
</code></pre>
<h3 id="hive-sitexml-&#x6587;&#x4EF6;"><code>hive-site.xml</code> &#x6587;&#x4EF6;</h3>
<p>&#x7528;&#x6765;&#x8FDE;&#x63A5; Linux &#x4E2D;&#x7684; Hive</p>
<pre class="language-"><code class="lang-xml"><span class="token prolog">&lt;?xml version=&quot;1.0&quot;?&gt;</span>
<span class="token prolog">&lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;configuration.xsl&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>configuration</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>javax.jdo.option.ConnectionURL<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>value</span><span class="token punctuation">&gt;</span></span>jdbc:mysql://hadoop201:3306/metastore?createDatabaseIfNotExist=true<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>value</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>JDBC connect string for a JDBC metastore<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>javax.jdo.option.ConnectionDriverName<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>value</span><span class="token punctuation">&gt;</span></span>com.mysql.jdbc.Driver<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>value</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>Driver class name for a JDBC metastore<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>javax.jdo.option.ConnectionUserName<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>value</span><span class="token punctuation">&gt;</span></span>root<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>value</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>username to use against metastore database<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>javax.jdo.option.ConnectionPassword<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>value</span><span class="token punctuation">&gt;</span></span>aaa<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>value</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>password to use against metastore database<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!-- zookeeper &#x5730;&#x5740;--&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>hive.zookeeper.quorum<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>value</span><span class="token punctuation">&gt;</span></span>hadoop201,hadoop202,hadoop203<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>value</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>The list of ZooKeeper servers to talk to. This is only needed for read/write locks.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!-- zookeeper &#x7AEF;&#x53E3;&#x53F7; --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>hive.zookeeper.client.port<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>value</span><span class="token punctuation">&gt;</span></span>2181<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>value</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>The port of ZooKeeper servers to talk to. This is only needed for read/write locks.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>property</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>configuration</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<hr>
<h2 id="333-&#x521B;&#x5EFA;&#x9700;&#x8981;&#x7684;&#x7C7B;">3.3.3 &#x521B;&#x5EFA;&#x9700;&#x8981;&#x7684;&#x7C7B;</h2>
<h3 id="1-configurationutilscala-&#x6587;&#x4EF6;">1. <code>ConfigurationUtil.scala</code> &#x6587;&#x4EF6;</h3>
<p>&#x5728;&#x8FD9;&#x4E2A; scala &#x6587;&#x4EF6;&#x4E2D;&#x5B9A;&#x4E49;&#x8BFB;&#x53D6;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x7684;&#x4E00;&#x4E9B;&#x5DE5;&#x5177;</p>
<p>&#x4F4D;&#x4E8E;&#x5305;: <code>package com.atguigu.sparkmall.common.util</code></p>
<pre class="language-"><code class="lang-scala"><span class="token keyword">package</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>common<span class="token punctuation">.</span>util

<span class="token keyword">import</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>commons<span class="token punctuation">.</span>configuration2<span class="token punctuation">.</span>builder<span class="token punctuation">.</span>FileBasedConfigurationBuilder
<span class="token keyword">import</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>commons<span class="token punctuation">.</span>configuration2<span class="token punctuation">.</span>builder<span class="token punctuation">.</span>fluent<span class="token punctuation">.</span>Parameters
<span class="token keyword">import</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>commons<span class="token punctuation">.</span>configuration2<span class="token punctuation">.</span><span class="token punctuation">{</span>FileBasedConfiguration<span class="token punctuation">,</span> PropertiesConfiguration<span class="token punctuation">}</span>

<span class="token keyword">import</span> scala<span class="token punctuation">.</span>collection<span class="token punctuation">.</span>mutable

<span class="token comment">/**
  * &#x7528;&#x6765;&#x8BFB;&#x53D6;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x7684;&#x5DE5;&#x5177;&#x7C7B;
  */</span>
<span class="token keyword">object</span> ConfigurationUtil <span class="token punctuation">{</span>
    <span class="token comment">// &#x8FD9;&#x4E2A; map &#x7528;&#x6765;&#x5B58;&#x50A8;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x540D;&#x548C;&#x5728;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x5185;&#x5B9A;&#x4E49;&#x7684;&#x914D;&#x7F6E;</span>
    <span class="token keyword">private</span> <span class="token keyword">val</span> configs <span class="token operator">=</span> mutable<span class="token punctuation">.</span>Map<span class="token punctuation">[</span><span class="token builtin">String</span><span class="token punctuation">,</span> FileBasedConfiguration<span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token punctuation">)</span>

    <span class="token comment">// &#x53C2;&#x6570;&#x662F;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x540D;</span>
    <span class="token keyword">def</span> apply<span class="token punctuation">(</span>propertiesFileName<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token comment">// &#x6839;&#x636E;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x540D;&#x6765;&#x83B7;&#x53D6;&#x6765;&#x83B7;&#x53D6;&#x5BF9;&#x5E94;&#x7684;&#x914D;&#x7F6E;.  </span>
        <span class="token comment">// &#x5982;&#x679C; map &#x4E2D;&#x5B58;&#x5728;&#x8FD9;&#x4E00;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;, &#x5219;&#x8BFB;&#x53D6;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x7684;&#x5185;&#x5BB9;&#x5E76;&#x66F4;&#x65B0;&#x5230; map &#x4E2D;</span>
        configs<span class="token punctuation">.</span>getOrElseUpdate<span class="token punctuation">(</span>
            propertiesFileName<span class="token punctuation">,</span>
            <span class="token keyword">new</span> FileBasedConfigurationBuilder<span class="token punctuation">[</span>FileBasedConfiguration<span class="token punctuation">]</span><span class="token punctuation">(</span>classOf<span class="token punctuation">[</span>PropertiesConfiguration<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">.</span>configure<span class="token punctuation">(</span><span class="token keyword">new</span> Parameters<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>properties<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>setFileName<span class="token punctuation">(</span>propertiesFileName<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span>getConfiguration<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">def</span> main<span class="token punctuation">(</span>args<span class="token operator">:</span> Array<span class="token punctuation">[</span><span class="token builtin">String</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Unit</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token comment">// &#x6D4B;&#x8BD5;&#x662F;&#x5426;&#x53EF;&#x7528;</span>
        <span class="token keyword">val</span> conf <span class="token operator">=</span> ConfigurationUtil<span class="token punctuation">(</span><span class="token string">&quot;config.properties&quot;</span><span class="token punctuation">)</span>
        println<span class="token punctuation">(</span>conf<span class="token punctuation">.</span>getString<span class="token punctuation">(</span><span class="token string">&quot;jdbc.user&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>

    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="2-datamodelscala-&#x6587;&#x4EF6;">2. <code>DataModel.scala</code> &#x6587;&#x4EF6;</h3>
<p>&#x5728;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x4E2D;&#x5B9A;&#x4E49;&#x4E00;&#x4E9B;&#x7528;&#x6765;&#x5C01;&#x88C5;&#x6570;&#x636E;&#x7684;<code>bean</code>&#x7C7B;. &#x4E3A;&#x4E86;&#x65B9;&#x4FBF;, &#x6211;&#x4EEC;&#x4F7F;&#x7528; scala &#x7684;&#x6837;&#x4F8B;&#x7C7B;</p>
<p>&#x4F4D;&#x4E8E;&#x5305;: <code>com.atguigu.sparkmall.common.bean</code></p>
<pre class="language-"><code class="lang-scala"><span class="token keyword">package</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>common<span class="token punctuation">.</span>bean

<span class="token comment">/**
  * &#x7528;&#x6237;&#x8868;
  *
  * @param user_id      &#x7528;&#x6237; id
  * @param username     &#x7528;&#x6237;&#x7684;&#x767B;&#x5F55;&#x540D;
  * @param name         &#x7528;&#x6237;&#x7684;&#x6635;&#x79F0;&#x6216;&#x771F;&#x5B9E;&#x540D;
  * @param age          &#x7528;&#x6237;&#x5E74;&#x9F84;
  * @param professional &#x7528;&#x6237;&#x7684;&#x804C;&#x4E1A;
  * @param gender       &#x7528;&#x6237;&#x7684;&#x6027;&#x522B;
  */</span>
<span class="token keyword">case</span> <span class="token keyword">class</span> UserInfo<span class="token punctuation">(</span>user_id<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">,</span>
                    username<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                    name<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                    age<span class="token operator">:</span> <span class="token builtin">Int</span><span class="token punctuation">,</span>
                    professional<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                    gender<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">)</span>

<span class="token comment">/**
  * &#x57CE;&#x5E02;&#x8868;
  *
  * @param city_id   &#x57CE;&#x5E02; id
  * @param city_name &#x57CE;&#x5E02;&#x540D;
  * @param area      &#x57CE;&#x5E02;&#x533A;&#x57DF;
  */</span>
<span class="token keyword">case</span> <span class="token keyword">class</span> CityInfo<span class="token punctuation">(</span>city_id<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">,</span>
                    city_name<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                    area<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">)</span>

<span class="token comment">/**
  * &#x4EA7;&#x54C1;&#x8868;
  *
  * @param product_id   &#x5546;&#x54C1;&#x7684;ID
  * @param product_name &#x5546;&#x54C1;&#x7684;&#x540D;&#x79F0;
  * @param extend_info  &#x5546;&#x54C1;&#x989D;&#x5916;&#x7684;&#x4FE1;&#x606F;
  */</span>
<span class="token keyword">case</span> <span class="token keyword">class</span> ProductInfo<span class="token punctuation">(</span>product_id<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">,</span>
                       product_name<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                       extend_info<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">)</span>

<span class="token comment">/**
  * &#x7528;&#x6237;&#x8BBF;&#x95EE;&#x52A8;&#x4F5C;&#x8868;
  *
  * @param date               &#x7528;&#x6237;&#x70B9;&#x51FB;&#x884C;&#x4E3A;&#x7684;&#x65E5;&#x671F;
  * @param user_id            &#x7528;&#x6237;&#x7684;ID
  * @param session_id         Session&#x7684;ID
  * @param page_id            &#x67D0;&#x4E2A;&#x9875;&#x9762;&#x7684;ID
  * @param action_time        &#x52A8;&#x4F5C;&#x7684;&#x65F6;&#x95F4;&#x70B9;
  * @param search_keyword     &#x7528;&#x6237;&#x641C;&#x7D22;&#x7684;&#x5173;&#x952E;&#x8BCD;
  * @param click_category_id  &#x67D0;&#x4E00;&#x4E2A;&#x5546;&#x54C1;&#x54C1;&#x7C7B;&#x7684;ID
  * @param click_product_id   &#x67D0;&#x4E00;&#x4E2A;&#x5546;&#x54C1;&#x7684;ID
  * @param order_category_ids &#x4E00;&#x6B21;&#x8BA2;&#x5355;&#x4E2D;&#x6240;&#x6709;&#x54C1;&#x7C7B;&#x7684;ID&#x96C6;&#x5408;
  * @param order_product_ids  &#x4E00;&#x6B21;&#x8BA2;&#x5355;&#x4E2D;&#x6240;&#x6709;&#x5546;&#x54C1;&#x7684;ID&#x96C6;&#x5408;
  * @param pay_category_ids   &#x4E00;&#x6B21;&#x652F;&#x4ED8;&#x4E2D;&#x6240;&#x6709;&#x54C1;&#x7C7B;&#x7684;ID&#x96C6;&#x5408;
  * @param pay_product_ids    &#x4E00;&#x6B21;&#x652F;&#x4ED8;&#x4E2D;&#x6240;&#x6709;&#x5546;&#x54C1;&#x7684;ID&#x96C6;&#x5408;
  */</span>
<span class="token keyword">case</span> <span class="token keyword">class</span> UserVisitAction<span class="token punctuation">(</span>date<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                           user_id<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">,</span>
                           session_id<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                           page_id<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">,</span>
                           action_time<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                           search_keyword<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                           click_category_id<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">,</span>
                           click_product_id<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">,</span>
                           order_category_ids<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                           order_product_ids<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                           pay_category_ids<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                           pay_product_ids<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                           city_id<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">)</span>
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; &#x5C1A;&#x7845;&#x8C37;&#x5927;&#x6570;&#x636E; 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification"><br>&#x8BE5;&#x6587;&#x4EF6;&#x6700;&#x540E;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2019-03-19 10:04:56
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="31-chuang-jian-fu-gong-cheng.html" class="navigation navigation-prev " aria-label="Previous page: 3.1 创建父工程">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.html" class="navigation navigation-next " aria-label="Next page: 3.3 创建模拟数据子模块">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3.2 创建通用子模块","level":"1.3.2","depth":2,"next":{"title":"3.3 创建模拟数据子模块","level":"1.3.3","depth":2,"path":"di-3-zhang-xiang-mu-da-jian/33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.md","ref":"di-3-zhang-xiang-mu-da-jian/33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.md","articles":[]},"previous":{"title":"3.1 创建父工程","level":"1.3.1","depth":2,"path":"di-3-zhang-xiang-mu-da-jian/31-chuang-jian-fu-gong-cheng.md","ref":"di-3-zhang-xiang-mu-da-jian/31-chuang-jian-fu-gong-cheng.md","articles":[]},"dir":"ltr"},"config":{"plugins":["splitter","expandable-chapters-small","page-toc-button","-highlight","prism","prism-themes","tbfed-pagefooter","sitemap","change_girls","livereload"],"styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy 尚硅谷大数据 2019","modify_label":"<br>该文件最后修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prismjs/themes/prism-solarizedlight.css"]},"disqus":{"shortName":"zhenchao125"},"livereload":{},"splitter":{},"change_girls":{"time":30,"urls":["http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/62171757.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/83394736.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/15906185.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/15906185.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/3394270.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/65028582.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/20359261.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/37472401.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/3355397.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/11075549.jpg-atguiguImg"]},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"sitemap":{"hostname":"http://bigdataatguigu.applinzi.com/"},"page-toc-button":{"maxTocDepth":3,"minTocSize":2},"prism-themes":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":" 李振超","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"大数据 bigdata_mallanalyze_atguigu 课堂笔记","language":"zh-hans","links":{"sidebar":{"联系我们":"http://www.atguigu.com/"}},"gitbook":"*","description":"课堂笔记,学生提前预习"},"file":{"path":"di-3-zhang-xiang-mu-da-jian/32-chuang-jian-gong-zuo-zi-mo-kuai.md","mtime":"2019-03-19T02:04:56.222Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-19T00:04:29.500Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-page-toc-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-change_girls/girls.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

